package main

import "fmt"

type TreeNode struct {
	Val         int
	Left, Right *TreeNode
}

func isSymmetric(root *TreeNode) bool {
	if root == nil {
		return true
	}
	return isSymmetricChild(root.Left, root.Right)
}

func isSymmetricChild(left, right *TreeNode) bool {
	if left == nil && right == nil {
		return true
	}
	if (left != nil && right == nil) || (right != nil && left == nil) {
		return false
	}
	if left.Val != right.Val {
		return false
	}
	return isSymmetricChild(left.Left, right.Right) && isSymmetricChild(right.Left, left.Right)
}

func main() {
	var a, b TreeNode
	a.Left = &b
	fmt.Println(a, b)
	fmt.Println(isSymmetric(&a))
}
